<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>users</title>
<jsp:include page="header.jsp"></jsp:include>
<script type="text/javascript">
$(function(){
	//分页显示用户列表
	$('#dg').datagrid({    
	    url:'../goods/indexShow', 
	   		title:'首页商品列表',
			iconCls:'icon-save',
			fitColumns:true,
			striped:true,
			pagination:true,
			rownumbers:true,
			fit:true,
			columns:[[        
	        {field:'gname',title:'商品名',width:100},    
	        {field:'fileName',title:'预览主显图片',width:150,height:80,align:'left',
	        	formatter:function(value, rec){//使用formatter格式化刷子
	        		return '<img src='+'../images/'+value+'>';
	        	}},
	        {field:'fileName_1',title:'详细图片1',width:150,height:80,align:'left',
	        	formatter:function(value, rec){//使用formatter格式化刷子
	        		return '<img src='+'../images/'+value+'>';
	        	}},
	        {field:'fileName_2',title:'详细图片2',width:150,height:80,align:'left',
	        	formatter:function(value, rec){//使用formatter格式化刷子
	        		return '<img src='+'../images/'+value+'>';
	        	}},
	        {field:'fileName_3',title:'详细图片3',width:150,height:80,align:'left',
	        	formatter:function(value, rec){//使用formatter格式化刷子
	        		return '<img src='+'../images/'+value+'>';
	        	}},
	        {field:'price',title:'商品价格',width:100},
	        {field:'count',title:'商品库存',width:200},
	        {field:'summary',title:'商品简介',width:200},
	        {field:'factory',title:'生产厂家',width:200},
	        {field:'content',title:'详细信息',width:200},
	        {field:'spec',title:'商品规格',width:200},
	        {field:'gclass',title:'商品类别',width:100},
	        {field:'hot',title:'商品人气',width:200},
	        {field:'sid',title:'店铺id',width:200},
	        {field:'type_id',title:'所属分类',width:200},
	        {field:'index_id',title:'所属首页商品栏目',width:200},
	        {field:'state',title:'商品状态',width:200},
	        {field:'address_id',title:'所在区域',width:200},
	        {field:'minorder',title:'最低起定量',width:200}
	    ]], 
	    toolbar: [{
		iconCls: 'icon-edit',
		handler: disableGoods,
		text:'下架商品',
		}]  
	}) 
	
});
	//1.下架商品
	function disableGoods(){
		var selectedrow=$("#dg").datagrid("getSelected");
		if(selectedrow){
			$.messager.confirm('确认对话框', '您确认要下架此商品吗', function(r){
				if (r){
				    // 禁用操作;发送一个ajax请求
				    $.get("../goods/disable",{gid:selectedrow.gid},function(message){
				    	$.messager.show({
							title:'提示消息',
							msg:message.msg,
							timeout:2000,
							showType:'slide'
						});
				    	if(message.success){
				    		$("#dg").datagrid("reload");
				    	}
				    },"json")
				}
			});
		}else{
			$.messager.show({
				title:'提示消息',
				msg:'请选择您要删除的行。',
				timeout:2000,
				showType:'slide'
			});
		}
	} 
</script>
</head>
<body>
	<table id="dg"></table> 
	
</body>
</html>